package com.thingsgrid.appmanager.controller;

import com.thingsgrid.appmanager.feign.FileFeign;
import com.thingsgrid.appmanager.util.FileProcess;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 功能说明：文件处理controller
 *
 * @author 李龙飞
 * @since 2019/8/30 17:02
 */

@RestController
public class FileController implements FileFeign {


	/**
	 *说明：文件上传
	 *@author lilongfei
	 *@since 2019/8/30 17:15
	 */
	@Override
	@PostMapping(value = "file/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public String uploadFile(@RequestPart("file")MultipartFile file){
		String filePath="";
		try {
			filePath = FileProcess.fileUpload(file,file.getOriginalFilename());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return filePath;
	}

}
